var ctx;

var title = "";

function setCtx(ctx){
	this.ctx = ctx;
}
function gotoPage(page){
	title = ifNull($("#title").val());
	//解决ie9以下placeholder与value重复的问题
	if(title == $("#title").attr("placeholder")){
		title = "";
	}
	loadContent("/storeInfo/storeBannerList?pNo="+ page +"&title="+ title);
}

function gotoStoreBannerPage(page) {
	if(page == null){
		page = $(".inputclass").val();
	}
	title = ifNull($("#title").val());
	//解决ie9以下placeholder与value重复的问题
	if(title == $("#title").attr("placeholder")){
		title = "";
	}
	loadContent("/storeInfo/storeBannerList?pNo="+ page +"&title="+ title);
}

function ifNull(mess){
	if(mess == null || mess == undefined){
		mess = "";
	}
	
	return mess;
}

//条件搜索菜单列表
function getStoreBannerList(){
	title = ifNull($("#title").val());
	//解决ie9以下placeholder与value重复的问题
	if(title == $("#title").attr("placeholder")){
		title = "";
	}
	loadContent("/storeInfo/storeBannerList?pNo=1&title="+ title);
	
}



//新增或编辑用户(1:新增 2:编辑)
function saveOrUpdate (id) {
	if(id != null){
		loadContent("/storeInfo/storeBannerEdit?id="+id+"");
	}else{
		loadContent("/storeInfo/storeBannerEdit?id=0");
	}
	
}

function updateSort(storeBannerId){
	if(storeBannerId != null){
   		$.get(ctx + "/storeInfo/updateSort",{
			id: storeBannerId
   		},function(data){
	    data = JSON.parse(data);
		if(data.success){
			layer.msg("操作成功",{
			    icon: 1,
			    time: 2000 //2秒关闭（如果不配置，默认是3秒）
			},function(){
				loadContent("/storeInfo/storeBannerList");
			});
		}else{
			layer.msg(data.msg,{
			    icon: 2,
			    time: 2000 //2秒关闭（如果不配置，默认是3秒）
			});
		}
	});
	}
}

function deleteStoreBanner(storeBannerId){
	if(storeBannerId != null){
		layer.confirm('确认删除?', {icon: 3, title:'提示'}, function(index){
			$.get(ctx + "/storeInfo/deleteStoreBanner",{
				id: storeBannerId
	   		},function(data){
	        data = JSON.parse(data);
			if(data.success){
				layer.msg("操作成功",{
				    icon: 1,
				    time: 2000 //2秒关闭（如果不配置，默认是3秒）
				},function(){
					loadContent("/storeInfo/storeBannerList");
				});
			}else{
				layer.msg(data.msg,{
				    icon: 2,
				    time: 2000 //2秒关闭（如果不配置，默认是3秒）
				});
			}
		});
		    layer.close(index);
		});
	}
}